Micron Document
🎖️GitЯра🎖️


Displaying Raw • Download

core/ui/src/commonMain/kotlin/org/meshtastic/core/ui/component/NodeCardGlow.kt 01cd54907d62cd90913d3d071b6bc240cae365ef (01cd5490) Text, 2.88 KB

T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tf0883e@fileTb4b4b4:Te6edf3SuppressTb4b4b4(Ta5d6ff"Ta5d6ffMagicNumberTa5d6ff"Tb4b4b4)

Tff7b72package T7ee787org.meshtastic.core.ui.component

Tff7b72import T7ee787androidx.compose.animation.core.Animatable
Tff7b72import T7ee787androidx.compose.material3.CardDefaults
Tff7b72import T7ee787androidx.compose.material3.MaterialTheme
Tff7b72import T7ee787androidx.compose.runtime.Composable
Tff7b72import T7ee787androidx.compose.runtime.LaunchedEffect
Tff7b72import T7ee787androidx.compose.runtime.mutableIntStateOf
Tff7b72import T7ee787androidx.compose.runtime.remember
Tff7b72import T7ee787androidx.compose.ui.Modifier
Tff7b72import T7ee787androidx.compose.ui.draw.shadow
Tff7b72import T7ee787androidx.compose.ui.graphics.Color
Tff7b72import T7ee787androidx.compose.ui.unit.dp

Tff7b72private Tff7b72const Tff7b72val Te6edf3GLOW_MAX_ELEVATION_DP Tff7b72= T79c0ff8

T8b949e/**
* A modifier that applies a glow animation to a node card when a packet is received.
*
* The glow blooms quickly using [MaterialTheme.motionScheme.fastSpatialSpec] and decays slowly using
* [MaterialTheme.motionScheme.slowSpatialSpec], creating an M3 Expressive motion effect.
*
* @param lastHeard The node's lastHeard timestamp. Changes trigger the glow animation.
* @param nodeColor The color used for the glow shadow (typically the node's assigned color).
*/
Tf0883e@Composable
Tff7b72fun Te6edf3ModifierTb4b4b4.Td2a8ffnodeCardGlowTb4b4b4(Te6edf3lastHeardTb4b4b4: Tffa657IntTb4b4b4, Te6edf3nodeColorTb4b4b4: Te6edf3ColorTb4b4b4)Tb4b4b4: Te6edf3Modifier Tb4b4b4{
Tff7b72val Te6edf3glowAlpha Tff7b72= Te6edf3remember Tb4b4b4{ Te6edf3AnimatableTb4b4b4(T79c0ff0fTb4b4b4) Tb4b4b4}
Tff7b72val Te6edf3bloomSpec Tff7b72= Te6edf3MaterialThemeTb4b4b4.Te6edf3motionSchemeTb4b4b4.Te6edf3fastSpatialSpecTff7b72<Tffa657FloatTff7b72>Tb4b4b4(Tb4b4b4)
Tff7b72val Te6edf3decaySpec Tff7b72= Te6edf3MaterialThemeTb4b4b4.Te6edf3motionSchemeTb4b4b4.Te6edf3slowSpatialSpecTff7b72<Tffa657FloatTff7b72>Tb4b4b4(Tb4b4b4)
Tff7b72val Te6edf3cardShape Tff7b72= Te6edf3CardDefaultsTb4b4b4.Te6edf3shape

T8b949e// Track previous value to distinguish initial composition from actual changes
Tff7b72val Te6edf3previousLastHeard Tff7b72= Te6edf3remember Tb4b4b4{ Te6edf3mutableIntStateOfTb4b4b4(Te6edf3lastHeardTb4b4b4) Tb4b4b4}
Te6edf3LaunchedEffectTb4b4b4(Te6edf3lastHeardTb4b4b4) Tb4b4b4{
Tff7b72if Tb4b4b4(Te6edf3lastHeard Tff7b72> T79c0ff0 Tff7b72&Tff7b72& Te6edf3lastHeard Tff7b72!Tff7b72= Te6edf3previousLastHeardTb4b4b4.Te6edf3intValueTb4b4b4) Tb4b4b4{
Te6edf3glowAlphaTb4b4b4.Te6edf3animateToTb4b4b4(Te6edf3targetValue Tff7b72= T79c0ff1fTb4b4b4, Te6edf3animationSpec Tff7b72= Te6edf3bloomSpecTb4b4b4)
Te6edf3glowAlphaTb4b4b4.Te6edf3animateToTb4b4b4(Te6edf3targetValue Tff7b72= T79c0ff0fTb4b4b4, Te6edf3animationSpec Tff7b72= Te6edf3decaySpecTb4b4b4)
Tb4b4b4}
Te6edf3previousLastHeardTb4b4b4.Te6edf3intValue Tff7b72= Te6edf3lastHeard
Tb4b4b4}

Tff7b72val Te6edf3alpha Tff7b72= Te6edf3glowAlphaTb4b4b4.Te6edf3value
Tff7b72return Tff7b72if Tb4b4b4(Te6edf3alpha Tff7b72> T79c0ff0fTb4b4b4) Tb4b4b4{
Tff7b72thisTb4b4b4.Te6edf3shadowTb4b4b4(
Te6edf3elevation Tff7b72= Te6edf3GLOW_MAX_ELEVATION_DPTb4b4b4.Te6edf3dp Tff7b72* Te6edf3alphaTb4b4b4,
Te6edf3shape Tff7b72= Te6edf3cardShapeTb4b4b4,
Te6edf3ambientColor Tff7b72= Te6edf3nodeColorTb4b4b4.Te6edf3copyTb4b4b4(Te6edf3alpha Tff7b72= Te6edf3alphaTb4b4b4)Tb4b4b4,
Te6edf3spotColor Tff7b72= Te6edf3nodeColorTb4b4b4.Te6edf3copyTb4b4b4(Te6edf3alpha Tff7b72= Te6edf3alphaTb4b4b4)Tb4b4b4,
Tb4b4b4)
Tb4b4b4} Tff7b72else Tb4b4b4{
Tff7b72this
Tb4b4b4}
Tb4b4b4}

Served by rngit 1.5.0 - Generated in 0.05s